--------------------------------------------------------------------------------------------------------
       log:  C:\DATA\cox.log
  log type:  text
 opened on:  25 Apr 2006, 13:18:24

. #delimit ;
delimiter now ;
. *     ***************************************************************** *;
. *     ***************************************************************** *;
. *       File-Name:      cox.do                                          *;
. *       Date:           4/15/06                                         *;
. *       Author:         MRG                                             *;
. *       Purpose:        PA Article using Amorim Neto and Cox 1997 data  *;
. *       Input File:     coxappend.dta                                   *;
. *       Output File:    cox.log                                         *;
. *       Data Output:    coxappend.dta                                   *;
. *       Previous file:                                                  *;
. *       Machine:                                                        *;
. *     ****************************************************************  *;
. *     ****************************************************************  *;
. set mem 10m;
(10240k)

. use "C:\Documents and Settings\matt\My Documents\politicalanalysis\coxappend.dta", clear;

. *     ****************************************************************  *;
. *           Summary Statistics                                          *;
. *     ****************************************************************  *;
. sum;

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
       var12 |         0
        drop |        54    .0555556    .2312123          0          1
        year |        54    1985.167    1.969101       1981       1990
        enpv |        54    3.530846    1.728027     1.8444    10.3233
        enps |        54     2.93345     1.43717     1.1796       8.69
-------------+--------------------------------------------------------
       eneth |        54    1.572086    .6820787       1.01     3.7736
          ml |        54    12.32407    25.62891          1        150
       upper |        54    .0410163     .104919          0     .49799
      enpres |        54    1.146883    1.707402          0      5.689
    proximit |        54    .2861111    .4214683          0          1
-------------+--------------------------------------------------------
        lnml |        54    1.530797     1.37122          0   5.010635
    lmleneth |        54    2.324924     2.37556          0    10.8008
        smdp |        54    .3703704    .4874383          0          1
     smdpeth |        54    .6470183    .9896785          0     3.5562
       multi |        54    .5185185    .5043487          0          1
-------------+--------------------------------------------------------
     enpvlml |        54    6.221569    6.778793          0   32.92359
     enpvUpp |        54    .2287147    .7268405          0      3.916
      multiV |        54    .5185185    .5043487          0          1
       enpvQ |        54    1.537037    1.127913          0          3
    enpvmult |        54    2.308235     2.63141          0    10.3233
-------------+--------------------------------------------------------
    enpvsmdp |        54    .9894981    1.376881          0       4.13
    proxpres |        54    .9413589    1.484606          0      5.178
       drop2 |        54    .0925926    .2925824          0          1

. *     ****************************************************************  *;
. *                           Dichotomize the Data                        *;
. *     ****************************************************************  *;
. gen multiparty=.;
(54 missing values generated)

. replace multiparty=1 if enps>2.99;
(20 real changes made)

. replace multiparty=0 if enps<3;
(34 real changes made)

. gen multimember=.;
(54 missing values generated)

. replace multimember=1 if ml>1;
(34 real changes made)

. replace multimember=0 if ml==1;
(20 real changes made)

. tab multiparty multimember;

           |      multimember
multiparty |         0          1 |     Total
-----------+----------------------+----------
         0 |        17         17 |        34 
         1 |         3         17 |        20 
-----------+----------------------+----------
     Total |        20         34 |        54 


. *     ****************************************************************  *;
. *       Dichotomize eneth 1>median, 0 otherwise.                        *;
. *     ****************************************************************  *;
. sum eneth, detail;

                      Eff Ethnic Groups
-------------------------------------------------------------
      Percentiles      Smallest
 1%         1.01           1.01
 5%       1.0121         1.0121
10%     1.040799         1.0121       Obs                  54
25%        1.105         1.0202       Sum of Wgt.          54

50%       1.2775                      Mean           1.572086
                        Largest       Std. Dev.      .6820787
75%       1.7188         2.7563
90%       2.5974         3.4625       Variance       .4652314
95%       3.4625         3.4922       Skewness       1.666059
99%       3.7736         3.7736       Kurtosis       5.122842

. gen heterogeneity=.;
(54 missing values generated)

. replace heterogeneity=1 if eneth>1.2775;
(27 real changes made)

. replace heterogeneity=0 if eneth<1.2775;
(27 real changes made)

. *     ****************************************************************  *;
. *       Graph of legislative parties against ln(magnitude).             *;
. *     ****************************************************************  *;
. graph twoway scatter enps lnml, mlabel(var12) mlabsize(2) msize(1) 
> xlabel(0 1 2 3 4 5 6, labsize(2.5)) ylabel(1 3 5 7 9, 
> labsize(2.5)) title("Figure 3: The Relationship between Electoral Laws 
> and Party System Size", size(4)) xtitle(Log of Median District 
> Magnitude, size(3)) ytitle(Effective Number of Legislative Parties, 
> size(3)) yline(1 3 5 7 9, lcolor(white)) scheme(s2mono) graphregion(fcolor(white));

. *     ****************************************************************  *;
. *       Get standard deviations around mean of legislative parties in   *;
. *       single member and multi-member districts.                       *;
. *     ****************************************************************  *;
. sum enps if multi==1;

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
        enps |        28    3.856754    1.450493     2.4644       8.69

. sum enps if multi==0;

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
        enps |        26    1.939123    .3514352     1.1796     2.4501

. *     ****************************************************************  *;
. *       Run regression for results with dichotomous variables.          *;
. *     ****************************************************************  *;
. gen multi_heterogeneity = multimember*heterogeneity;

. regress enps heterogeneity multimember multi_heterogeneity;

      Source |       SS       df       MS              Number of obs =      54
-------------+------------------------------           F(  3,    50) =    7.35
       Model |  33.4971669     3  11.1657223           Prob > F      =  0.0004
    Residual |  75.9721185    50  1.51944237           R-squared     =  0.3060
-------------+------------------------------           Adj R-squared =  0.2644
       Total |  109.469285    53  2.06545822           Root MSE      =  1.2327

------------------------------------------------------------------------------
        enps |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
heterogene~y |  -.8336323    .554038    -1.50   0.139     -1.94645    .2791856
 multimember |   .5455444     .50323     1.08   0.284    -.4652227    1.556312
multi_hete~y |   1.654754   .6973784     2.37   0.022     .2540281     3.05548
       _cons |   2.516478   .4108855     6.12   0.000      1.69119    3.341766
------------------------------------------------------------------------------

. *     ****************************************************************  *;
. *       Predicted number of parties - homogenous and single-member      *;
. *     ****************************************************************  *;
. lincom 1*_cons;

 ( 1)  _cons = 0

------------------------------------------------------------------------------
        enps |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         (1) |   2.516478   .4108855     6.12   0.000      1.69119    3.341766
------------------------------------------------------------------------------

. *     ****************************************************************  *;
. *       Predicted number of parties - heterogeneous and single-member   *;
. *     ****************************************************************  *;
. lincom 1*_cons + 1*heterogeneity;

 ( 1)  heterogeneity + _cons = 0

------------------------------------------------------------------------------
        enps |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         (1) |   1.682845     .37166     4.53   0.000     .9363445    2.429346
------------------------------------------------------------------------------

. *     ****************************************************************  *;
. *       Predicted number of parties - homongeous and multi-member       *;
. *     ****************************************************************  *;
. lincom 1*_cons + 1* multimember;

 ( 1)  multimember + _cons = 0

------------------------------------------------------------------------------
        enps |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         (1) |   3.062022     .29054    10.54   0.000     2.478456    3.645589
------------------------------------------------------------------------------

. *     ****************************************************************  *;
. *       Predicted number of parties - heterogeneous and multi-member    *;
. *     ****************************************************************  *;
. lincom 1*_cons + 1* multimember +1*heterogeneity + 1*multi_heterogeneity;

 ( 1)  heterogeneity + multimember + multi_heterogeneity + _cons = 0

------------------------------------------------------------------------------
        enps |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         (1) |   3.883144   .3081642    12.60   0.000     3.264178     4.50211
------------------------------------------------------------------------------

. *     ****************************************************************  *;
. *       Calculate marginal effects with dichotomous variables           *;
. *     ****************************************************************  *;
. regress enps heterogeneity multimember multi_heterogeneity;

      Source |       SS       df       MS              Number of obs =      54
-------------+------------------------------           F(  3,    50) =    7.35
       Model |  33.4971669     3  11.1657223           Prob > F      =  0.0004
    Residual |  75.9721185    50  1.51944237           R-squared     =  0.3060
-------------+------------------------------           Adj R-squared =  0.2644
       Total |  109.469285    53  2.06545822           Root MSE      =  1.2327

------------------------------------------------------------------------------
        enps |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
heterogene~y |  -.8336323    .554038    -1.50   0.139     -1.94645    .2791856
 multimember |   .5455444     .50323     1.08   0.284    -.4652227    1.556312
multi_hete~y |   1.654754   .6973784     2.37   0.022     .2540281     3.05548
       _cons |   2.516478   .4108855     6.12   0.000      1.69119    3.341766
------------------------------------------------------------------------------

. lincom 1*heterogeneity;

 ( 1)  heterogeneity = 0

------------------------------------------------------------------------------
        enps |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         (1) |  -.8336323    .554038    -1.50   0.139     -1.94645    .2791856
------------------------------------------------------------------------------

. lincom 1*heterogeneity + 1*multi_heterogeneity, level(94);

 ( 1)  heterogeneity + multi_heterogeneity = 0

------------------------------------------------------------------------------
        enps |      Coef.   Std. Err.      t    P>|t|     [94% Conf. Interval]
-------------+----------------------------------------------------------------
         (1) |   .8211215   .4235311     1.94   0.058     .0060626     1.63618
------------------------------------------------------------------------------

. *     ****************************************************************  *;
. *       Run regression for results with continuous variables.           *;
. *     ****************************************************************  *;
. regress  enps eneth lnml lmleneth;

      Source |       SS       df       MS              Number of obs =      54
-------------+------------------------------           F(  3,    50) =    9.49
       Model |  39.7248824     3  13.2416275           Prob > F      =  0.0000
    Residual |   69.744403    50  1.39488806           R-squared     =  0.3629
-------------+------------------------------           Adj R-squared =  0.3247
       Total |  109.469285    53  2.06545822           Root MSE      =  1.1811

------------------------------------------------------------------------------
        enps |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
       eneth |  -.3619712   .3486305    -1.04   0.304    -1.062216    .3382737
        lnml |  -.1911174   .2967357    -0.64   0.522    -.7871287    .4048939
    lmleneth |   .4833254   .1805094     2.68   0.010     .1207616    .8458893
       _cons |   2.671367   .6072149     4.40   0.000      1.45174    3.890994
------------------------------------------------------------------------------

. generate JH=((_n-1)/10);

. replace JH=. if _n>52;
(2 real changes made, 2 to missing)

. matrix b=e(b);

.  matrix V=e(V);

.  scalar b1=b[1,1];

.  scalar b2=b[1,2];

. scalar b3=b[1,3];

. scalar varb1=V[1,1];

.  scalar varb2=V[2,2];

.  scalar varb3=V[3,3];

. scalar covb1b3=V[1,3];

.  scalar covb2b3=V[2,3];

. set more off;

. *     ****************************************************************  *;
. *         Create full range of marginal effect                          *;
. *     ****************************************************************  *;
. gen conb=b1+b3*JH if _n<52;
(3 missing values generated)

. set more off;

. *     ****************************************************************  *;
. *           Create full range of standard errors                        *;
. *     ****************************************************************  *;
. gen conse=sqrt(varb1+varb3*JH^2+2*covb1b3*JH)  if _n<52;
(3 missing values generated)

.  set more off;

. *     ****************************************************************  *;
. *               Generate confidence intervals at the 95% level          *;
. *     ****************************************************************  *;
. gen a=1.96*conse;
(3 missing values generated)

.  gen top=conb+a;
(3 missing values generated)

.  gen bottom=conb-a;
(3 missing values generated)

. set textsize 100;

. graph twoway  line conb JH, clwidth(medium) clcolor(blue) clcolor(black)
>         ||  line top  JH, clpattern(dash) clwidth(thin) clcolor(black)
>         ||  line bottom JH, clpattern(dash) clwidth(thin) clcolor(black)
>         ||  ,   
>             xlabel(0 1 2 3 4 5 , labsize(2.5)) 
>             ylabel(-2 0 2 4 , labsize(2.5))
>             yscale(noline)
>             xscale(noline)
>             legend(col(1) order(1 2) label(1 "Marginal Effect of Social Heterogeneity") label(2 "95%
>  Confidence Interval") 
>                   label(3 " "))
>         yline(0, lcolor(black)) yline(2 4 , lcolor(white))  
>             title("Figure 4: Marginal Effect of Social Heterogeneity", size(4))
>             subtitle(" " "Dependent Variable: Effective Number of Legislative Parties" " ", size(3))
>             xtitle(Logged Median District Magnitude, size(3)  )
>         xsca(titlegap(2))
>         ysca(titlegap(2))
>             ytitle("Marginal Effect of Social Heterogeneity" , size(3))
>         scheme(s2mono) graphregion(fcolor(white));

. save    cox, replace;
file cox.dta saved

.  exit;

end of do-file

. log close
       log:  C:\DATA\cox.log
  log type:  text
 closed on:  25 Apr 2006, 13:21:40
------------------------------------------------------------------------------------------------------
